//       https://www.nowcoder.com/practice/65cfde9e5b9b4cf2b6bafa5f3ef33fa6





class Solution
{
public:
    ListNode* mergeKLists(vector<ListNode*>& lists)
    {
        vector<int> a;
        for (int i = 0; i < lists.size(); i++)
            while (lists[i])
            {
                a.push_back(lists[i]->val);
                lists[i] = lists[i]->next;
            }
        sort(a.begin(), a.end());

        ListNode* h = new ListNode(0);
        ListNode* ans = h;
        for (auto x : a)
        {
            h->next = new ListNode(x);
            h = h->next;
        }
        return ans->next;
    }
};